DifferentialMotionFlingController

Controller differential motion flings.

Differential motion here refers to motions that report change in position instead of absolution position. For instance, differential data points of 2, -1, 5 represent: there was a movement by "2" units, then by "-1" units, then by "5" units. Examples of motions reported differentially include motions from AXIS_SCROLL.

The client should call onMotionEvent when a differential motion event happens on the target View (that is, the View on which we want to fling), and this class processes the event to orchestrate fling.

Note that this class currently works to control fling only in one direction at a time. As such, it works independently of horizontal/vertical orientations. It requests its client to start/stop fling, and it's up to the client to choose the fling direction based on its specific internal configurations and/or preferences.

Constructors

Link copied to clipboard
constructor(@NonNull context: Context, @NonNull target: DifferentialMotionFlingTarget)
Constructs an instance for a given DifferentialMotionFlingTarget.

Functions

Link copied to clipboard
open fun onMotionEvent(@NonNull event: MotionEvent, axis: Int)
Called to report when a differential motion happens on the View that's the target for fling.